package com.yian.houseproperty.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yian.houseproperty.entity.Carinfo;
import com.yian.houseproperty.service.ICarinfoService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yian
 * @since 2022-03-14
 */
@RestController
@RequestMapping("/car")
public class CarinfoController {
    @Resource
    private ICarinfoService carinfoService;
    @GetMapping("/selectAll")
    public List<Carinfo> selectAll(){
        return carinfoService.list();
    }
    @GetMapping("/selectMycars/{oid}")
    public List<Carinfo> selectMycars(@PathVariable Integer oid){
        QueryWrapper<Carinfo> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("oid",oid);
        return carinfoService.list(queryWrapper);
    }
    @DeleteMapping("/del/{cid}")
    public void del(@PathVariable Integer cid){
        carinfoService.removeById(cid);
    }
    @PostMapping("/add")
    public void add(@RequestBody Carinfo car){
        carinfoService.save(car);
    }
}

